ifdef CFG_LOCAL_CARGO
CARGO := $(CFG_LOCAL_CARGO)
else
-CARGO := $(TARGET_ROOT)/snapshot/cargo/bin/cargo$(X)
+CARGO := $(TARGET_ROOT)/snapshot/bin/cargo$(X)
endif
all: $(foreach target,$(CFG_TARGET),cargo-$(target))
endef
$(foreach target,$(CFG_TARGET),$(eval $(call CARGO_TARGET,$(target))))
-$(TARGET_ROOT)/snapshot/cargo/bin/cargo$(X): src/snapshots.txt
+$(TARGET_ROOT)/snapshot/bin/cargo$(X): src/snapshots.txt
$(CFG_PYTHON) src/etc/dl-snapshot.py $(CFG_BUILD)
touch $@
- python src/etc/dl-snapshot.py %TARGET%
- call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" %ARCH%
- SET PATH=%PATH%;%cd%/rustc/bin
- - SET PATH=%PATH%;%cd%/target/snapshot/cargo/bin
+ - SET PATH=%PATH%;%cd%/target/snapshot/bin
- if defined NEEDS_LIBGCC set PATH=%PATH%;C:\MinGW\bin
- rustc -V
- cargo -V
if h != hash:
raise Exception("failed to verify the checksum of the snapshot")
-download.unpack(dl_path, dst)
+download.unpack(dl_path, dst, strip=2)
run(["curl", "-o", path, url], quiet=quiet)
-def unpack(tarball, dst, quiet=False):
+def unpack(tarball, dst, quiet=False, strip=0):
if quiet:
print("extracting " + tarball)
- fname = os.path.basename(tarball).replace(".tar.gz", "")
with contextlib.closing(tarfile.open(tarball)) as tar:
- for p in tar.getnames():
- name = p.replace(fname + "/", "", 1)
- fp = os.path.join(dst, name)
- if not quiet:
- print("extracting " + p)
- tar.extract(p, dst)
- tp = os.path.join(dst, p)
- if os.path.isdir(tp) and os.path.exists(fp):
+ for p in tar.getmembers():
+ if p.isdir():
+ continue
+ path = []
+ p2 = p.name
+ while p2 != "":
+ a, b = os.path.split(p2)
+ path.insert(0, b)
+ p2 = a
+ if len(path) <= strip:
continue
- shutil.move(tp, fp)
- shutil.rmtree(os.path.join(dst, fname))
+ fp = os.path.join(dst, *path[strip:])
+ if not quiet:
+ print("extracting " + p.name)
+ contents = tar.extractfile(p)
+ if not os.path.exists(os.path.dirname(fp)):
+ os.makedirs(os.path.dirname(fp))
+ open(fp, 'wb').write(contents.read())
+ os.chmod(fp, p.mode)
def run(args, quiet=False):
extra_bits = 'i686'
extra = None
-libdir = 'lib'
# Figure out our target triple
if sys.platform == 'linux' or sys.platform == 'linux2':
host = host_bits + '-apple-darwin'
extra = extra_bits + '-apple-darwin'
elif sys.platform == 'win32':
- libdir = 'bin'
if os.environ.get('MSVC') == '1':
host = host_bits + '-pc-windows-msvc'
extra = extra_bits + '-pc-windows-msvc'
if os.path.isdir("rustc-install"):
shutil.rmtree("rustc-install")
+ # Download the compiler
host_fname = 'rustc-nightly-' + host + '.tar.gz'
download.get(url + '/' + host_fname, host_fname)
- download.unpack(host_fname, "rustc-install", quiet=True)
+ download.unpack(host_fname, "rustc-install", quiet=True, strip=2)
os.remove(host_fname)
+ # Download all target libraries needed
+ fetch_std(host)
if extra is not None:
- extra_fname = 'rustc-nightly-' + extra + '.tar.gz'
- print("adding target libs for " + extra)
- download.get(url + '/' + extra_fname, extra_fname)
- folder = extra_fname.replace(".tar.gz", "")
- with contextlib.closing(tarfile.open(extra_fname)) as tar:
- for p in tar.getnames():
- if not "rustc/" + libdir + "/rustlib/" + extra in p:
- continue
- name = p.replace(folder + "/", "", 1)
- dst = "rustc-install/" + name
- tar.extract(p, "rustc-install")
- tp = os.path.join("rustc-install", p)
- if os.path.isdir(tp) and os.path.exists(dst):
- continue
- shutil.move(tp, dst)
- shutil.rmtree("rustc-install/" + folder)
- os.remove(extra_fname)
+ fetch_std(extra)
if os.path.isdir("rustc"):
shutil.rmtree("rustc")
- os.rename("rustc-install/rustc", "rustc")
- shutil.rmtree("rustc-install")
+ os.rename("rustc-install", "rustc")
+
+def fetch_std(target):
+ fname = 'rust-std-nightly-' + target + '.tar.gz'
+ print("adding target libs for " + target)
+ download.get(url + '/' + fname, fname)
+ download.unpack(fname, "rustc-install", quiet=True, strip=2)
+ os.remove(fname)
install_via_tarballs()
.file("src/lib.rs", r#"
#![feature(plugin_registrar, rustc_private)]
- extern crate rustc;
+ extern crate rustc_plugin;
extern crate baz;
- use rustc::plugin::Registry;
+ use rustc_plugin::Registry;
#[plugin_registrar]
pub fn foo(_reg: &mut Registry) {
"#)
.file("bar/src/lib.rs", &format!(r#"
#![feature(plugin_registrar, rustc_private)]
- extern crate rustc;
+ extern crate rustc_plugin;
- use rustc::plugin::Registry;
+ use rustc_plugin::Registry;
#[link(name = "{}")]
extern {{ fn foo(); }}
.file("src/lib.rs", r#"
#![feature(plugin_registrar, quote, rustc_private)]
- extern crate rustc;
+ extern crate rustc_plugin;
extern crate syntax;
- use rustc::plugin::Registry;
+ use rustc_plugin::Registry;
use syntax::ast::TokenTree;
use syntax::codemap::Span;
use syntax::ext::base::{ExtCtxt, MacEager, MacResult};
.file("src/lib.rs", r#"
#![feature(plugin_registrar, quote, rustc_private)]
- extern crate rustc;
+ extern crate rustc_plugin;
extern crate syntax;
extern crate baz;
- use rustc::plugin::Registry;
+ use rustc_plugin::Registry;
use syntax::ast::TokenTree;
use syntax::codemap::Span;
use syntax::ext::base::{ExtCtxt, MacEager, MacResult};
.file("src/lib.rs", r#"
#![feature(plugin_registrar, rustc_private)]
- extern crate rustc;
+ extern crate rustc_plugin;
extern crate baz;
- use rustc::plugin::Registry;
+ use rustc_plugin::Registry;
#[plugin_registrar]
pub fn foo(reg: &mut Registry) {